package com.os.opencv.java.chapter4;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;

public class Add {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //读取图像文件并在屏幕上显示
        Mat src1 = Imgcodecs.imread("/Users/matt/MATT-MAC/matt_workspace/OS-OpenCV_workspace/img1.png");
        Mat src2 = Imgcodecs.imread("/Users/matt/MATT-MAC/matt_workspace/OS-OpenCV_workspace/img2.png");

        //在屏幕上显示两幅图像
        HighGui.imshow("src1", src1);
        HighGui.waitKey(0);
        HighGui.imshow("src2", src2);
        HighGui.waitKey(0);

        //将两幅图像甲醛相加并在屏幕上显示
        Mat dst = new Mat();
        Core.addWeighted(src1, 0.5, src2, 0.5, 0, dst);
        HighGui.imshow("mixed", dst);
        HighGui.waitKey(0);

    }
}
